#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'tian'
__data__ = '2022/3/15 17:40'
# software: PyCharm

from django import forms
from apps.app01 import models
from .bootstrap import BootStrapForm


class DomainModelForm(BootStrapForm, forms.ModelForm):

    class Meta:
        model = models.Domain
        fields = ["site_type","url_name","context","comment"]
        widgets ={
            "context": forms.Select(attrs={'class': "form-select"}),
            "site_type":forms.Select(attrs={'class': "form-select"}),
        }

    def __init__(self,request,*args,**kwargs):
        super().__init__(*args,**kwargs)
        # 处理初始化数据
        module_list = [("","请选择"),]
        self.fields["site_type"].choices = module_list + self.fields.get("site_type").choices[1:]


